<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
  <h1>hello product</h1>
    <button>add</button>
    <script>
      let btn=document.querySelector("button")
      btn.addEventListener("click",()=>{
          let product={name:"aaa",stock:23};
          let info=JSON.stringify(product)
         fetch("http://localhost:8080/products", {method:"POST",
         headers:{'Content-Type':'application/json'},body:info} )
         .then(resp=>resp.json())
         .then(p=>console.log(p))

      })
    </script>
</body>
</html>